From d386a228cbc937a5a1128698a09da30a3b3a00ac Mon Sep 17 00:00:00 2001 From: oliskoli Date: Sun, 29 Jul 2007 19:05:43 +0000 Subject: [PATCH] unicsv: Change output format for 'microseconds'. If we have ONE, we'll get ONE. --- unicsv.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/unicsv.c b/unicsv.c index a5e22cf6d..3895966c0 100644 --- a/unicsv.c +++ b/unicsv.c @@ -1033,10 +1033,19 @@ unicsv_waypt_disp_cb(const waypoint *wpt) if (wpt->creation_time != 0) { struct tm tm; char buf[32], msec[12]; + tm = *localtime(&wpt->creation_time); snprintf(buf, sizeof(buf), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec); + if (wpt->microseconds > 0) { - snprintf(msec, sizeof(msec), ".%d", wpt->microseconds / 1000); + int len = 6; + int ms = wpt->microseconds; + + while (len && (ms == (int)((double)ms / 10) * 10)) { + ms /= 10; + len--; + } + snprintf(msec, sizeof(msec), ".%0*d", len, ms); strcat(buf, msec); } gbfprintf(fout, "%s%s", unicsv_fieldsep, buf); -- 2.30.2